Beyond jQuery by Ray Nicholus
Author:Ray Nicholus
Language: eng
Format: epub
Publisher: Apress, Berkeley, CA
At the top of the preceding code, I’m simply selecting elements needed by our move operation. The last line is the most important one. Since the insertBefore() method is defined on the Node object’s prototype, we must call insertBefore() on an DOM object that implements this interface. In fact, this element must be a parent element of the Node we are moving. Since we are moving the “vanilla” <li> element, we can use its parent—the “flavors” <ul>.
The first parameter passed to insertBefore() is the element we want to relocate: the “vanilla” list item. The second parameter is the “reference node.” This is the Node that will become the next sibling of our target element (the “vanilla” <li>) after the move operation. Since we want to move “vanilla” before “strawberry,” the “strawberry” <li> is our reference node.
We’ve reordered our flavors, but we still need to move the flavors heading and list to the top of our document. We can easily accomplish this goal with the insertBefore() method as well:
1 var headings = document.querySelectorAll('h2'),
2 flavorsHeading = headings[0],
3 typesHeading = headings[1],
4 typesList = document.querySelector('.types');
5
6 document.body.insertBefore(typesHeading, flavorsHeading);
7 document.body.insertBefore(typesList, flavorsHeading);
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
AI & Machine Learning | Bioinformatics |
Computer Simulation | Cybernetics |
Human-Computer Interaction | Information Theory |
Robotics | Systems Analysis & Design |
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(7878)
Hadoop in Practice by Alex Holmes(5671)
Jquery UI in Action : Master the concepts Of Jquery UI: A Step By Step Approach by ANMOL GOYAL(5527)
Life 3.0: Being Human in the Age of Artificial Intelligence by Tegmark Max(4534)
Functional Programming in JavaScript by Mantyla Dan(3733)
The Age of Surveillance Capitalism by Shoshana Zuboff(3442)
Big Data Analysis with Python by Ivan Marin(3161)
Blockchain Basics by Daniel Drescher(2906)
The Rosie Effect by Graeme Simsion(2729)
Test-Driven Development with Java by Alan Mellor(2690)
WordPress Plugin Development Cookbook by Yannick Lefebvre(2645)
Hands-On Machine Learning for Algorithmic Trading by Stefan Jansen(2565)
Data Augmentation with Python by Duc Haba(2544)
Applied Predictive Modeling by Max Kuhn & Kjell Johnson(2500)
Dawn of the New Everything by Jaron Lanier(2449)
Principles of Data Fabric by Sonia Mezzetta(2351)
The Infinite Retina by Robert Scoble Irena Cronin(2341)
The Art Of Deception by Kevin Mitnick(2312)
Rapid Viz: A New Method for the Rapid Visualization of Ideas by Kurt Hanks & Larry Belliston(2213)